import React,{Component} from 'react';
import { View, Text, TextInput, Button } from 'react-native';

class My extends Component{

    constructor(){
        super();
        this.state={
            username:'',
            password:'',
        }
    }



    // 登录按钮的事件
    _buttononpress(){
        fetch('http://houdunren.com/login', {
            method: 'POST',
            body: JSON.stringify({
                name: this.state.title,
                password: this.state.password,
        })
        }).then(x => {

        })
    }


    
    render() {
        return (
            <View style={{justifyContent:'center',alignItems:'center',flex:1}}>
                <Text style={{fontSize:25}}>用户名：{this.state.username} 密码：{this.state.password}</Text>
                <TextInput
                    placeholder={'用户名：'}
                    onChangeText={value=>{
                        this.setState({
                            username:value
                        })
                    }}
                />
                <TextInput
                    placeholder={'密码：'}
                    onChangeText={value=>{
                        this.setState({
                            password:value
                        })
                    }}
                />
                <Button title={"登录"} onPress={this._buttononpress.bind(this)} />
            </View>
        )
    }
}

export default My;